package com.mzz.behavior.state.state;

/**
 * 状态模式的切换类
 * @author xushijian
 * @date 18/5/16
  上午9:44
 */
public class Context {

    private State state;

    public Context(State state) {
        this.state = state;
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    //不同的状态执行不同的逻辑
    public void method() {

        if (state.getValue().equals("method1")) {// 第一种状态
            state.method1();
        } else if (state.getValue().equals("method2")) {//第二种状态
            state.method2();
        }
    }

}
